<?php
namespace app\yunda\model;

use think\Model;

/**
 * 地区表
 * @package app\yunda\model
 */
class China extends Model
{
    protected $table = 'dp_yd_region';

    //获取某一级地区
    public static function getProvince($pid=1,$type='admin',$extra=null)
    {
        $map['pid']=$pid;
        if($type=='admin'){
            if($extra!==null){
                $map['region_type']=$extra;
                unset($map['pid']);
            }
            $list=self::where($map)->column('id,name');
        }elseif ($type=='home'){
            $list=collection(self::where($map)->field('id,name,region_type')->select())->toArray();
        }
        return $list;
    }
    //获取某个地区
    public static function getPlace($id=0)
    {
        $map['id']=$id;
        $list=self::where($map)->find();
        return $list;
    }

}
